package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.TradingPoolAccount;
import com.sc.nft.mapper.TradingPoolAccountMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author PC
 * @description 针对表【sc_trading_pool_account(交易池账户)】的数据库操作Dao
 * @createDate 2024-10-26 13:52:01
 */
@Slf4j
@Repository
public class TradingPoolAccountDao extends ServiceImpl<TradingPoolAccountMapper, TradingPoolAccount> {

    /**
     * 根据品牌获取交易池账号
     *
     * @param daoId
     * @return
     */
    public List<TradingPoolAccount> listByDaoId(Long daoId) {
        LambdaQueryWrapper<TradingPoolAccount> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TradingPoolAccount::getDaoId, daoId);
        wrapper.orderByAsc(TradingPoolAccount::getId);
        return list(wrapper);
    }

    /**
     * 添加礼包收入账户余额
     *
     * @param id
     * @param amount
     * @return
     */
    public Boolean addGiftIncomeAccount(Long id, BigDecimal amount) {
        return baseMapper.addGiftIncomeAccount(id, amount) > 0;
    }

    /**
     * 扣减礼包收入账户金额
     *
     * @param amount
     * @return
     */
    public Boolean reduceGiftIncomeAccount(Long id, BigDecimal amount) {
        return baseMapper.reduceGiftIncomeAccount(id, amount) > 0;
    }

    /**
     * 添加冻结账户余额
     *
     * @param id
     * @param amount
     * @return
     */
    public Boolean addFrozenAccount(Long id, BigDecimal amount) {
        return baseMapper.addFrozenAccount(id, amount) > 0;
    }

    /**
     * 扣减冻结账户余额
     *
     * @param id
     * @param amount
     * @return
     */
    public Boolean reduceFrozenAccount(Long id, BigDecimal amount) {
        return baseMapper.reduceFrozenAccount(id, amount) > 0;
    }

    public Boolean frozenToGiftIncomeAccount(Long id, BigDecimal amount) {
        return baseMapper.frozenToGiftIncomeAccount(id, amount) > 0;
    }

    /**
     * 礼包收入账户入金
     * @param daoId
     * @param amount
     * @return
     */
    public Boolean depositIntoTheGiftPackageAccount(Long daoId,BigDecimal amount){
        return baseMapper.depositIntoTheGiftPackageAccount(daoId, amount) > 0;
    }

}
